'use strict';
import * as Koa from 'koa';
import { router, prefix } from '../middleware/router';
import { response } from '../middleware/result';
import { activityService } from '../service/activity';

/** 首页活动对象 */
@prefix('activity')
class activityController {
    /**
     * 
     * @api {post} /activity/query  查询banner
     * @apiDescription 查询banner
     * @apiName query
     * @apiParam (参数) {String} offset   页码
     * @apiParam (参数) {String} limit    每页显示条数
     * @apiParam (参数) {String} status   状态 1：有效 0：禁用
     * @apiSampleRequest /banner/query
     * @apiGroup banner
     * @apiVersion 1.0.0
     */
    @router('/query',{method: 'post'})
    async query(ctx: Koa.Context) {
        let result = await activityService.query(ctx.request.body);
        response(ctx, result);
    }
    /**
     * 
     * @api {post} /activity/save  保存活动信息
     * @apiDescription 保存banner信息
     * @apiName save
     * @apiParam (参数) {String} hrefurl   图片链接地址
     * @apiParam (参数) {String} img   图片
     * @apiParam (参数) {String} title   标题
     * @apiParam (参数) {String} type    类型 1：轮播图 2：优惠活动
     * @apiParam (参数) {String} createuser    创建人
     * @apiSampleRequest /banner/save
     * @apiGroup banner
     * @apiVersion 1.0.0
     */
    @router('/save',{method: 'post'})
    async save(ctx: Koa.Context) {
        let result = await activityService.save(ctx.request.body);
        response(ctx, result);
    }
}